<?php


namespace app\modules\Admin\models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class twostageModel extends Model
{
    protected $table = 'twostage';
    protected $primaryKey = 'twostage_id';
    protected $appends = [];
    protected $hidden = [];

    /**
     * @param DateTimeInterface $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function twostage_level()
    {
        return $this->belongsTo(twostagelevelModel::class, 'level', 'level');
    }

    public function member()
    {
        return $this->belongsTo(\memberModel::class, 'twostage_id', 'id');
    }

    public function twostage_last_log()
    {
        return $this->hasOne(twostagelogModel::class, 'twostage_id', 'twostage_id')->orderBy('id', 'desc');
    }

    public function twostage_log()
    {
        return $this->hasMany(twostagelogModel::class, 'twostage_id', 'twostage_id')->orderBy('id', 'desc');
    }
}